

import java.util.List;
import java.util.ArrayList;
import com.eep.order.*;


 /******************************************************************************
 * File:ShipingAppUI.java
 * Course: 17655
 * Project: Assignment 2
 * Copyright: Copyright (c) 2009 Carnegie Mellon University
 * Versions:
 *	2.0 February 2012 - Initial rewrite of original assignment 2 (swr).
 *
 * This class defines a GUI application that allows EEP shipping personnel to
 * mark orders as shipped.
 *
 ******************************************************************************/
/*
 * Created on Feb 4, 2010, 7:40:03 PM
 *
 * @author lattanze updated by Steve Rosemergy
 */
public class ShippingAppUI extends javax.swing.JFrame {
    Integer updateOrderID = null;
    String versionID = "v3.00.00";
    com.eep.shipping.ShippingServiceDelegate shippingServiceDelegate;
    com.eep.shipping.ShippingService shippingService;
    
    
    /** Creates new form ShippingAppUI */
    public ShippingAppUI() {
        initComponents();

        // Create business Delegate to connect to a shipping service
        shippingServiceDelegate = new com.eep.shipping.ShippingServiceDelegate();
        // return an interface to the shipping service
        shippingService = shippingServiceDelegate.getShippingService();
        
        jLabel1.setText("Shipping Application " + versionID);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaOrders = new javax.swing.JTextArea();
        jTextFieldFirstName = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldLastName = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldPhone = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreaMailingAddress = new javax.swing.JTextArea();
        jButtonMarkAsShipped = new javax.swing.JButton();
        jButtonShowPendingOrders = new javax.swing.JButton();
        jButtonGetSelectedOrder = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextAreaOrderItems = new javax.swing.JTextArea();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButtonShowShippedOrders = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextAreaMessages = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldOrderDate = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Shipping Application");

        jTextAreaOrders.setColumns(20);
        jTextAreaOrders.setEditable(false);
        jTextAreaOrders.setRows(5);
        jTextAreaOrders.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jTextAreaOrdersPropertyChange(evt);
            }
        });
        jScrollPane1.setViewportView(jTextAreaOrders);

        jTextFieldFirstName.setEditable(false);

        jLabel4.setText("Order Information:");

        jLabel5.setText("Customer First Name:");

        jLabel6.setText("Last Name:");

        jTextFieldLastName.setEditable(false);

        jLabel7.setText("Phone Number:");

        jTextFieldPhone.setEditable(false);

        jLabel8.setText("Mailing Address");

        jTextAreaMailingAddress.setColumns(20);
        jTextAreaMailingAddress.setEditable(false);
        jTextAreaMailingAddress.setRows(5);
        jScrollPane2.setViewportView(jTextAreaMailingAddress);

        jButtonMarkAsShipped.setText("Mark As Shipped");
        jButtonMarkAsShipped.setEnabled(false);
        jButtonMarkAsShipped.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonMarkAsShippedActionPerformed(evt);
            }
        });

        jButtonShowPendingOrders.setText("Show  Pending Orders");
        jButtonShowPendingOrders.setDefaultCapable(false);
        jButtonShowPendingOrders.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonShowPendingOrdersActionPerformed(evt);
            }
        });

        jButtonGetSelectedOrder.setText("Select Order");
        jButtonGetSelectedOrder.setEnabled(false);
        jButtonGetSelectedOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonGetSelectedOrderActionPerformed(evt);
            }
        });

        jLabel10.setText("Order Number : Order Date & Time: Customer Name");

        jTextAreaOrderItems.setColumns(20);
        jTextAreaOrderItems.setEditable(false);
        jTextAreaOrderItems.setRows(5);
        jScrollPane3.setViewportView(jTextAreaOrderItems);

        jLabel9.setText("Order Items ");

        jLabel11.setText("Messages");

        jButtonShowShippedOrders.setText("Show Shipped Orders");
        jButtonShowShippedOrders.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonShowShippedOrdersActionPerformed(evt);
            }
        });

        jTextAreaMessages.setColumns(20);
        jTextAreaMessages.setEditable(false);
        jTextAreaMessages.setRows(5);
        jScrollPane4.setViewportView(jTextAreaMessages);

        jLabel2.setText("Order Date:");

        jTextFieldOrderDate.setEditable(false);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addContainerGap())
                    .addComponent(jLabel4)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel10)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 662, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 339, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel1)
                                .addGap(228, 228, 228))
                            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 410, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 101, Short.MAX_VALUE)
                                .addComponent(jButtonMarkAsShipped, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 415, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
                                .addComponent(jButtonGetSelectedOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jButtonShowShippedOrders, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButtonShowPendingOrders, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jTextFieldFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel5))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel6)
                                    .addComponent(jTextFieldLastName, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7)
                                    .addComponent(jTextFieldPhone, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(10, 10, 10)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 131, Short.MAX_VALUE))
                                    .addComponent(jTextFieldOrderDate, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE))))
                        .addGap(45, 45, 45))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonShowPendingOrders)
                .addGap(8, 8, 8)
                .addComponent(jButtonShowShippedOrders)
                .addGap(18, 18, 18)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButtonGetSelectedOrder, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldOrderDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jTextFieldPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(14, 14, 14)
                        .addComponent(jLabel11))
                    .addComponent(jButtonMarkAsShipped, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /////////////////////////////////////////////////////
    // User Interface Event Handlers
    private void jButtonShowPendingOrdersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowPendingOrdersActionPerformed
        // jButton2 is responsible for refreshing the list of pending
        // orders.

        // Clean up the form before we start

        jTextAreaOrders.setText("");
        jTextAreaMailingAddress.setText("");
        jTextAreaOrderItems.setText("");
        jTextFieldFirstName.setText("");
        jTextFieldLastName.setText("");
        jTextFieldPhone.setText("");
        jTextFieldOrderDate.setText("");
        
        jButtonMarkAsShipped.setEnabled(false);


        jTextAreaOrders.setText(getOrders(false));
        if (!jTextAreaOrders.getText().isEmpty())
            jButtonGetSelectedOrder.setEnabled(true);


    }//GEN-LAST:event_jButtonShowPendingOrdersActionPerformed

    private void jButtonGetSelectedOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonGetSelectedOrderActionPerformed
        // This button gets the selected line of text from the
        // order list window jTextAreaPendingOrders. The line of text is parsed for the
        // order number. Once the order number is parsed, then the order is
        // retrieved from the orders database. The ordertabel field from the
        // record contains the name of the table that has the items that make
        // up the order. This table is opened and all the items are listed
        // in jTextArea3.

  
        int beginIndex;                     // Parsing index
        int endIndex;                       // Parsing index
        String orderSelection = null;       // Order selected from TextArea1
        String orderID = null;              // Product ID pnemonic
        Boolean orderBlank = false;         // False: order string is not blank
        
        com.eep.order.OrderDetailed selectedOrder = null;  // Order Selected in the list
        com.eep.common.Customer selectedCustomer = null; // Customer associated with selected Item
        List <com.eep.order.OrderLineItem> purchasedItems = null; // list of items purchased by Customer
        com.eep.order.OrderLineItem currentItem = null;
      

        // this is the selected line of text
        orderSelection =  jTextAreaOrders.getSelectedText();

        // make sure its not blank
        if (orderSelection.length() > 0 )
        {
            // get the product ID
            beginIndex = 0;
            beginIndex = orderSelection.indexOf(" # ", beginIndex);
            beginIndex = beginIndex + 3; //skip past _#_
            endIndex = orderSelection.indexOf(" :", beginIndex);
            orderID = orderSelection.substring(beginIndex,endIndex);

        }
        else {

            jTextAreaMessages.setText("\n >> Valid order not selected...");
            orderBlank = true;

        } // Blank string check

        // If an order was selected, then connect to the orderinfo database. In
        // all normal situations this would be impossible to do since the select
        // button is disabled until an order is selected... just in case the
        // check is here.

        if ( !orderBlank )
        {
           try
           {
             selectedOrder = getOrderDetails(Integer.parseInt(orderID));
             selectedCustomer = selectedOrder.getCustomer();
             purchasedItems = getPurchases (selectedOrder);

             jTextFieldFirstName.setText(selectedCustomer.getFirstName()); // first name
             jTextFieldLastName.setText(selectedCustomer.getLastName()); // last name
             jTextFieldPhone.setText(selectedCustomer.getPhoneNumber()); // phone
             jTextFieldOrderDate.setText(selectedOrder.getDate()); // order date
             jTextAreaMailingAddress.setText(selectedCustomer.getAddress());  // address

             if (purchasedItems.size() > 0)
             {
                for (int n = 0; n< purchasedItems.size(); n++)
                {
                    currentItem = purchasedItems.get(n);
                    jTextAreaOrderItems.append ("PRODUCT ID: " + currentItem.getProductId() + "  DESCRIPTION: "+ currentItem.getDescription() + "  PRICE $" + currentItem.getItemPrice() + "\n");

                } 
             }
             // Update the form
             jTextAreaMessages.setText("RECORD RETRIVED...");
             if (!selectedOrder.isShipped())
             {
                jButtonMarkAsShipped.setEnabled(true);
                updateOrderID = selectedOrder.getId();
             }
           }
           catch (Exception e)
           {

                jTextAreaOrders.append(e.getMessage());

            } // end try-catch

        } 
        
    }//GEN-LAST:event_jButtonGetSelectedOrderActionPerformed

    private void jButtonMarkAsShippedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonMarkAsShippedActionPerformed
        // This method is responsible changing the status of the order
        // to shipped.

        if (updateOrderID != null)
            markAsShipped ();

        jTextAreaOrders.setText("");
        jTextAreaMailingAddress.setText("");
        jTextAreaOrderItems.setText("");
        jTextFieldFirstName.setText("");
        jTextFieldLastName.setText("");
        jTextFieldPhone.setText("");
        jTextFieldOrderDate.setText("");
        jButtonMarkAsShipped.setEnabled(false);


        jTextAreaOrders.setText(getOrders(false));


    }//GEN-LAST:event_jButtonMarkAsShippedActionPerformed

    private void jButtonShowShippedOrdersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonShowShippedOrdersActionPerformed
         // Clean up the form before we start

        jTextAreaOrders.setText("");
        jTextAreaMailingAddress.setText("");
        jTextAreaOrderItems.setText("");
        jTextFieldFirstName.setText("");
        jTextFieldLastName.setText("");
        jTextFieldPhone.setText("");
        jTextFieldOrderDate.setText("");
        jButtonMarkAsShipped.setEnabled(false);


        jTextAreaOrders.setText(getOrders(true));
        if (!jTextAreaOrders.getText().isEmpty())
            jButtonGetSelectedOrder.setEnabled(true);

    }//GEN-LAST:event_jButtonShowShippedOrdersActionPerformed

    private void jTextAreaOrdersPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jTextAreaOrdersPropertyChange
        jButtonMarkAsShipped.setEnabled(false);
    }//GEN-LAST:event_jTextAreaOrdersPropertyChange

    ///////////////////////////////////////////////////////
    // Shipping Service call-return methods
    private String getOrders(Boolean shipped) {

       
        com.eep.common.Customer currentCustomer;
        List<com.eep.order.OrderSummary> orderSummaryList;
        com.eep.order.OrderSummary currentOrder;
        String pendingOrderList = "";
        String orderState = "ORDER # ";
        updateOrderID = null;
        Boolean shippingServiceError = false;


    
        // Get orders from shipping service
        try
        {
           

            if (!shipped)
                orderSummaryList = shippingService.getPendingOrders();

            else
            {
                orderSummaryList = shippingService.getShippedOrders();
                orderState = "SHIPPED " + orderState;
            }
        } 
        
        catch (Exception e)
        {
            jTextAreaMessages.append("\nProblem connecting to Shipping Service:: " + e.getMessage());
            shippingServiceError = true;
            return null;

        } // end try-catch

        // If we are get the data, then parse out the pending orders

        if ( !shippingServiceError )
        {
            try
            {
                
                //Display the data in the textarea
                jTextAreaOrders.setText("");

           
                 for (int n = 0; n < orderSummaryList.size(); n++ )
                 {
                    currentOrder = orderSummaryList.get(n);
                    currentCustomer = currentOrder.getCustomer();

                   // Customer First and Last Names still need to be appended to this string...
                   pendingOrderList = pendingOrderList + orderState + Integer.toString(currentOrder.getId()) + " : " + currentOrder.getDate() + " : " + currentCustomer.getFirstName() + " : " + currentCustomer.getLastName() + "\n";
                   
                 }

            } 
            catch (Exception e)
            {

                jTextAreaMessages.append("\n Problem parsing Pending Orders:: " + e.getMessage());
                return null;

            } // end try-catch
            
        }
        return pendingOrderList;

    } // getOrders

    private OrderDetailed getOrderDetails(int orderId) {


        com.eep.order.OrderDetailed selectedOrder;
       
        // Get pending orders from shipping service
        try
        {


            selectedOrder = shippingService.getDetailedOrder(orderId);
            updateOrderID = null;

           
        }

        catch (Exception e)
        {
            jTextAreaMessages.append("\nProblem connecting to Shipping Service:: " + e.getMessage());
            return null;

        } // end try-catch

        // If we are get the data, then parse out the pending orders
        return selectedOrder;

    } // getOrdeDetails

    private List <OrderLineItem> getPurchases(OrderDetailed selectedOrder){
        List <OrderLineItem> purchasedItems = new ArrayList <OrderLineItem>();

        try
        {

          if (selectedOrder.getOrderLineItemCount() > 0)
          {
             for (int n = 0; n< selectedOrder.getOrderLineItemCount(); n++)
             purchasedItems.add(selectedOrder.getOrderLineItem(n));

          }


        }

        catch (Exception e)
        {
            jTextAreaMessages.append("\nProblem connecting to Shipping Service:: " + e.getMessage());
            return null;

        } // end try-catch

        // If we are get the data, then parse out the pending orders
        return purchasedItems;

    } // getPurchases

    private void markAsShipped (){

        // Get pending orders from shipping service
        com.eep.common.Status markedStatus;

        try
        {

            markedStatus = shippingService.markOrderAsShipped(updateOrderID, Boolean.TRUE);
            jTextAreaMessages.append(markedStatus.getMessage());
            updateOrderID = null;


        }

        catch (Exception e)
        {
            jTextAreaMessages.append("\nProblem connecting to Shipping Service:: " + e.getMessage());
          
            
        } // end try-catch

}

    // End Shipping Service Integrated Methods
    ///////////////////////////////////////////
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ShippingAppUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonGetSelectedOrder;
    private javax.swing.JButton jButtonMarkAsShipped;
    private javax.swing.JButton jButtonShowPendingOrders;
    private javax.swing.JButton jButtonShowShippedOrders;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTextArea jTextAreaMailingAddress;
    private javax.swing.JTextArea jTextAreaMessages;
    private javax.swing.JTextArea jTextAreaOrderItems;
    private javax.swing.JTextArea jTextAreaOrders;
    private javax.swing.JTextField jTextFieldFirstName;
    private javax.swing.JTextField jTextFieldLastName;
    private javax.swing.JTextField jTextFieldOrderDate;
    private javax.swing.JTextField jTextFieldPhone;
    // End of variables declaration//GEN-END:variables

}
